<template>
  <!-- 大小额贷记来账业务手工处理明细页面弹出框-->
  <el-dialog
    title="大小额贷记来账业务手工处理明细"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="false"
    @close="closeFn"
  >
    <el-form ref="settingsForm" :model="formData.data" :rules="rules" label-width="135px">
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>基本信息</span>
        </div>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="交易流水号：" prop="id">
              <el-input v-model="formData.data.id" placeholder="交易流水号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="系统编号：" prop="syscode">
              <el-select v-model="formData.data.syscode" placeholder="请选择" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dictMap.TXN_SYSCODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="工作日期：" prop="workdate">
              <el-date-picker
                disabled
                v-model="formData.data.workdate"
                type="date"
                value-format="yyyyMMdd"
                placeholder="选择日期"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="CPG日期：" prop="vdate">
              <el-date-picker
                disabled
                v-model="formData.data.vdate"
                type="date"
                value-format="yyyyMMdd"
                placeholder="选择日期"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="报文类型：" prop="pkgno">
              <el-select v-model="formData.data.pkgno" placeholder="请选择" style="width: 100%" disabled>
                <el-option
                  :label="`${formData.data.pkgno}-${formData.data.pkgnoDesc}`"
                  :value="formData.data.pkgno"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="业务类型：" prop="bizTypeCode">
              <el-select v-model="formData.data.bizTypeCode" placeholder="请选择" style="width: 100%" disabled>
                <el-option
                  :label="`${formData.data.bizTypeCode}-${formData.data.bizTypeCodeDesc}`"
                  :value="formData.data.bizTypeCode"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="业务种类：" prop="bizCtgyCode">
              <el-select v-model="formData.data.bizCtgyCode" placeholder="请选择" style="width: 100%" disabled>
                <el-option
                  :label="`${formData.data.bizCtgyCode}-${formData.data.bizCtgyCodeDesc}`"
                  :value="formData.data.bizCtgyCode"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="币种：" prop="curcd">
              <el-input v-model="formData.data.curcd" placeholder="币种" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="金额：" prop="amount">
              <el-input v-model="formData.data.amount" placeholder="金额" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="附言：" prop="remarks">
              <el-input
                disabled
                type="textarea"
                v-model="formData.data.remarks"
                placeholder="附言"
                maxlength="256"
                show-word-limit
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>付款人信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="付款人账号：" prop="payerActno">
              <el-input v-model="formData.data.payerActno" placeholder="付款人账号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款人名称：" prop="payerName">
              <el-input v-model="formData.data.payerName" placeholder="付款人名称" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="付款行行号：" prop="payerBrno">
              <el-input v-model="formData.data.payerBrno" placeholder="付款行行号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款行行名：" prop="payerBrname">
              <el-input v-model="formData.data.payerBrname" placeholder="付款行行名" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="付款人开户行行号：" prop="payerAccBrno">
              <el-input v-model="formData.data.payerAccBrno" placeholder="付款人开户行行号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款人开户行行名：" prop="payerAccBrName">
              <el-input v-model="formData.payerAccBrName" placeholder="付款人开户行行名" disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>收款人信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="收款人账号：" prop="payeeActno">
              <el-input v-model="formData.data.payeeActno" placeholder="收款人账号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款人名称：" prop="payeeName">
              <el-input v-model="formData.data.payeeName" placeholder="收款人名称" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="收款行行号：" prop="payeeBrno">
              <el-input v-model="formData.data.payeeBrno" placeholder="收款行行号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款行行名：" prop="payeeBrname">
              <el-input v-model="formData.data.payeeBrname" placeholder="收款行行名" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="收款人开户行行号：" prop="payeeAccBrno">
              <el-input v-model="formData.data.payeeAccBrno" placeholder="收款人开户行行号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款人开户行行名：" prop="payeeAccBrName">
              <el-input v-model="formData.payeeAccBrName" placeholder="收款人开户行行名" disabled />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>STP</span>
        </div>
        <el-row type="flex">
          <el-col :span="18">
            <el-form-item label="non-stp类型：" prop="nstpType">
              <el-select v-model="formData.data.nstpType" placeholder="请选择" style="width: 100%" disabled>
                <el-option
                  v-for="dict in dictMap.NON_STP_TYPE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="non-STP原因：" prop="nstpRemarks">
              <el-input
                disabled
                type="textarea"
                v-model="formData.data.nstpRemarks"
                placeholder="non-STP原因"
                maxlength="256"
                show-word-limit
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="接收时间：" prop="rcvTime">
              <el-date-picker
                disabled
                v-model="formData.data.rcvTime"
                type="date"
                value-format="yyyyMMdd"
                placeholder="选择时间"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12"></el-col>
        </el-row>
        <el-row v-if="formData.BIZ_TYPE_CODE != 'A105'">
          <el-col :span="24">
            <el-form-item label="退汇原因：" prop="reExchangeRemarks">
              <el-input
                type="textarea"
                v-model="formData.data.reExchangeRemarks"
                placeholder="退汇原因"
                maxlength="135"
                show-word-limit
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="danger" v-if="formData.BIZ_TYPE_CODE != 'A105'" @click="reexChangeFn" :loading="isLoading">
        退汇
      </el-button>
      <el-button type="primary" v-if="formData.data.nstpOptype != '09'" @click="delayFn" :loading="isLoading">
        推迟处理
      </el-button>
      <el-button type="primary" @click="forceSendFn" :loading="isLoading">强制发送</el-button>
      <el-button @click="cancel">取消</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { refundsave, fault, savetobank } from "@/api/cnaps/beps/baseHandWork/hvpsBepsCreditVostroHdWk";
import { log } from "util";
export default {
  name: "warningSetting",
  components: {},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      isControl: false,
      // 是否显示弹出层
      open: false,
      isLoading: false,
      rules: {
        reExchangeRemarks: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
      },
    };
  },
  mounted() {},
  methods: {
    // 表单重置
    reset() {
      this.resetForm("settingsForm");
      // this.$set(this, "form", {});
    },
    closeFn() {
      this.open = false;
    },
    show() {
      this.open = true;
    },
    // 退汇
    reexChangeFn() {
      this.$refs["settingsForm"].validate((valid) => {
        if (valid) {
          this.$confirm("是否选择退汇？", "系统提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            this.$set(this.formData.data, "optType", "00");
            refundsave(this.formData.data).then((res) => {
              this.msgSuccess("操作成功！");
              this.open = false;
              this.$emit("editComplete", true);
            });
          });
        }
      });
    },
    // 推迟处理
    delayFn() {
      this.$confirm("是否选择推迟处理？", "系统提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$set(this.formData.data, "optType", "09");
        fault(this.formData.data).then((res) => {
          this.msgSuccess("操作成功！");
          this.open = false;
          this.$emit("editComplete", true);
        });
      });
    },
    forceSendFn() {
      this.$confirm("强制发送后不再进行STP检查？", "系统提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$set(this.formData.data, "optType", "02");
        savetobank(this.formData.data).then((res) => {
          this.msgSuccess("操作成功！");
          this.open = false;
          this.$emit("editComplete", true);
        });
      });
    },
    cancel() {
      this.open = false;
      this.reset();
    },
  },
};
</script>
<style lang="scss" scoped>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
